package io.polly.ldz.webflux.config;


import io.polly.ldz.webflux.converter.QuestionConverter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.dialect.MySqlDialect;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;

/**
 * @author ldz112@163.com
 * @description：
 * @date 2025/3/13 10:03
 * Copyright (C) 2023 All Rights Reserved
 */
@EnableR2dbcRepositories
@Configuration
public class R2dbcConfiguration {

    @Primary//多个使用这个
    @Bean
    @ConditionalOnMissingBean
    public R2dbcCustomConversions r2dbcCustomConversions() {
        return R2dbcCustomConversions.of(MySqlDialect.INSTANCE, new QuestionConverter());
    }
}
